package com.xiaoluo.common.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.Random;

/**
 * Project : XL-Data
 * Package : com.xiaoluo.common.utils
 * Created by Willian.
 * Date  : 2015/12/2 12:23.
 */
public class Tools {

    private final static Logger logger = LoggerFactory.getLogger(Tools.class);

    private  static Random random = new Random();

    public static String trim(String value){
        return value.trim().replaceAll("\\n", "").replaceAll("\\r", "").replaceAll("&nbsp;", "").replaceAll("&nbsp", "").replaceAll("\\t", "").trim();
    }

    public static String extract(String value){
        return value.trim().replaceAll("&amp;", "&");
    }
    /**
     *
     * @param sec
     */
    public static void thinking(Integer sec){
        try {
            Thread.sleep(sec*1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    /**
     * Millis Sec
     * @param min
     * @param max
     */
    public static void thinking(Integer min,Integer max){


        int temp = random.nextInt(max);
        while (temp<min){
            temp = random.nextInt(max);
        }

        try {
            Thread.sleep(temp);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
